package Client;
import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Scanner;


public class Success extends JFrame 
{

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	static Success frame;
	public static void main(String[] args) 
	{
		EventQueue.invokeLater(new Runnable() 
		{
			public void run() 
			{
				try 
				{
					frame = new Success();
					frame.setVisible(true);
				} 
				catch (Exception e) 
				{
					e.printStackTrace();
				}
			}
		});
	}
	

	/**
	 * Create the frame.
	 */
	public Success() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton btnNewButton = new JButton("Yes");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				try {
					Transfer.read();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				}
		});
		btnNewButton.setBounds(96, 176, 89, 23);
		contentPane.add(btnNewButton);
		
		JButton btnNewButton_1 = new JButton("No");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Main_Screen  ms = new Main_Screen();
				ms.setVisible(true);
				//frame.setVisible(false);
			}
		});
		btnNewButton_1.setBounds(254, 176, 89, 23);
		contentPane.add(btnNewButton_1);
		
		JLabel lblSuccess = new JLabel("Success !!");
		lblSuccess.setFont(new Font("Tahoma", Font.PLAIN, 18));
		lblSuccess.setBounds(169, 11, 101, 42);
		contentPane.add(lblSuccess);
		
		JLabel lblDoYouWant = new JLabel("Do you want to synchronise with your friends ? ");
		lblDoYouWant.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblDoYouWant.setBounds(66, 111, 358, 42);
		contentPane.add(lblDoYouWant);
		
		JLabel lblOnlineFriendsList = new JLabel("Online Friends List Updated");
		lblOnlineFriendsList.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblOnlineFriendsList.setBounds(127, 38, 358, 42);
		contentPane.add(lblOnlineFriendsList);
	}
}















/*
 * int port=15011;
				String ip=new String("192.168.5.173");		//sever IP
				InetAddress ipad = null;
				int client_id = Sign_in.client_id;
				
				try {
					ipad = InetAddress.getByName(ip);
					Socket client = new Socket(ipad,port);
					
					BufferedReader inc  = new BufferedReader (new InputStreamReader(client.getInputStream()));
			        PrintWriter outc = new PrintWriter(new OutputStreamWriter(client.getOutputStream()));
					
			        BufferedReader inputStream = new BufferedReader(new FileReader("./src/list_client.txt"));
					int no_net=Integer.parseInt(inputStream.readLine());
					
					
					int [] gr_ids=new int[no_net];
					for(int i=0;i<no_net;i++)
					{
						gr_ids[i]=Integer.parseInt(inputStream.readLine());
					
						//System.out.println (gr_ids[i]);
					}

					//int syn;
			    	// Scanner in = new Scanner(System.in);
			    	// syn= in.nextInt();
			    	// outc.println(syn);
			    	// outc.flush();	 
			    	 
			    	 create_non_existing_gr_folders(gr_ids,no_net);
					// list_the_folder(gr_ids,no_net);
					  String temp;
					  BufferedWriter sync_ip = new BufferedWriter(new FileWriter("list_sync_ip.txt"));
					  while(true)
					 {	temp=inc.readLine();
						 System.out.println(temp);
							sync_ip.write(temp);
						 	sync_ip.newLine();
						if(temp.compareTo("a")==0)
							 break;
					 }
					 
					 sync_ip.close();
					  //
					 outc.close();
			         inc.close();			        	
			         Transfer.read();
			      
			         client.close();
*/
